import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-20
 * Time: 13:31
 */
public class Test67 {
//    输入：num = [4,5,6,7,0,1,2], target = 0
//    输出：4
    public static int search(int[] num, int target) {
        int n = num.length;
        int left = 0, right = n-1;
        if(n == 0 || num  == null) {
            return -1;
        }
        while(left <= right) {
            int mid = left+(right-left)/2;
            if(num[mid] == target) {
                return mid;
            }
            // 前半段有序
            if(num[left] <= num[mid]) {
                if(num[left] <= target && num[mid] > target) {
                    right = mid-1;
                }else {
                    left = mid+1;
                }
            // 后半段有序
            } else {
                if(num[right] >= target && num[mid] < target) {
                    left = mid+1;
                }else {
                    right = mid-1;
                }
            }

        }
        return -1;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int target = sc.nextInt();
        int ret = search(num,target);
        System.out.println(ret);
    }
}
